package com.oocl.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.dao.BookDao;
import com.oocl.dao.impl.BookDaoImpl;
import com.oocl.pojo.Book;
import com.oocl.pojo.GoodsInfo;
import com.oocl.pojo.User;

/**
 * Servlet implementation class ShoppingServlet
 */
public class ShoppingServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private BookDao bookDao;
	private List<GoodsInfo> goodsInfoList;
       
    public ShoppingServlet() {
        super();
        bookDao = new BookDaoImpl();
    }
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		User u1 = (User)request.getSession().getAttribute("user3");
		String name = u1.getName();
		List<Book> bookList = bookDao.findAllBook();
		goodsInfoList = (List<GoodsInfo>)request.getSession().getAttribute("goodsInfoList");
		request.setAttribute("user2", u1);
		request.setAttribute("booklist", bookList);
		//跳到jsp界面
		System.out.println(request.getSession().getAttribute("tt"));
		request.getRequestDispatcher("../shoppingCart.jsp").forward(request, response);
	}
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
